package adke.gui.panels;

import adke.gui.Overview;
import info.clearthought.layout.TableLayout;
import java.awt.Color;
import javax.swing.JPanel;

// het paneel waar het tekenpaneel en het scorepaneel in zitten

public class GamePanel extends JPanel
{
    private int scorePanelWidth = 200;
        
    private LinePanel linePanel;
    private ScoreHolderPanel scorePanel;
    
    private static GamePanel reference;
    
    public GamePanel()
    {
        reference = this;
        
        setBackground(Color.BLACK);
        
        // we houden twee randen vrij van 32pix als speling
        double[][] size = { {TableLayout.FILL, scorePanelWidth}, 
                        {TableLayout.FILL} };
        setLayout(new TableLayout(size));
        
        int frameW = getGameWidth();
        int frameH = getGameHeight();
        
        linePanel = new LinePanel(frameW, frameH);
        scorePanel = new ScoreHolderPanel();
        
        // het GFXPaneel wordt op het lijnpaneel zelf geplaatst ivm paint artefacten
        
        add(linePanel, "0, 0");
        add(scorePanel, "1, 0");
    }
    
    public int getGameWidth()
    {
        return Overview.getInstance().getWidth()-scorePanelWidth;
    }
    
    public int getGameHeight()
    {
        int h = Overview.getInstance().getHeight();
        
        // haal de grootte van de titlebar er van af
        if (!Overview.getInstance().isFullscreen()) h = h - 40;
        
        return h;
    }
    
    public LinePanel getLinePanel()
    {
        return linePanel;
    }
    
    public ScoreHolderPanel getScoreHolderPanel()
    {
        return scorePanel;
    }
    
    public static GamePanel getInstance()
    {
        return reference;
    }
}
